<!-- 管理员管理(超级管理员) -->
<template>
  <div class="adminMan-container">
    <addAdmin :total="adminDataRef.length" :adminNum="adminNumRef" @submitAddAdmin="getAdminData"></addAdmin>
    <selAdmin :adminData="adminDataRef" @handleDelete="getAdminData"></selAdmin>
  </div>
</template>

<script setup>
import addAdmin from './components/addAdmin.vue';
import selAdmin from './components/selAdmin.vue';
import {getAdmin} from "@/api/user.js"
import { ref } from 'vue';
const adminDataRef = ref([])
const adminNumRef = ref({}) // 管理员的数量
const getAdminData = async () => {
  const {data} = await getAdmin()
  adminDataRef.value = data;
  adminNumRef.value = adminDataRef.value.reduce((countMap,item)=>{
    countMap[item.authentication] = (countMap[item.authentication] || 0) + 1;
    return countMap
  },{})
}
getAdminData()



</script>

<style lang="less" scoped>
.adminMan-container{
    width: 100%;
    height: 100%;
}
</style>